package cn.zengchen233.service.impl;

import cn.zengchen233.dao.UserDao;
import cn.zengchen233.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * @author zengchen
 * @title UserServiceImpl
 * @description TODO
 * @create 2023/1/7 15:38
 */

@Service("userService")
@Scope("singleton")
public class UserServiceImpl implements UserService {
    @Autowired //按照数据类型从Spring容器进行匹配
    @Qualifier("userDao") //是按照id名称从容其中进行匹配的 但是此处@Qualifier需要结合@Autowired一起使用
    private UserDao userDao;

    @Override
    public void save() {
        userDao.save();
    }

    @PostConstruct
    public void init() {
        System.out.println("init...");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("destroy...");
    }
}
